<html>
<head><meta charset="utf-8"><title>closures used as fn pointers may be codegen&#x27;d downstream · t-compiler/performance · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/index.html">t-compiler/performance</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html">closures used as fn pointers may be codegen&#x27;d downstream</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="203704113"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704113" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704113">(Jul 13 2020 at 11:37)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> oh dear god I think I found the problem. I was right about a cursed thing happening</p>



<a name="203704387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704387">(Jul 13 2020 at 11:40)</a>:</h4>
<p>are all the fields directly written at installation time?</p>



<a name="203704408"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704408" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704408">(Jul 13 2020 at 11:41)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> nah it's not about any of the <code>Providers</code> value itself I don't think</p>



<a name="203704423"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704423" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704423">(Jul 13 2020 at 11:41)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> <a href="https://github.com/rust-lang/rust/pull/74283#issuecomment-657510352">https://github.com/rust-lang/rust/pull/74283#issuecomment-657510352</a></p>



<a name="203704480"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704480" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704480">(Jul 13 2020 at 11:42)</a>:</h4>
<p>I have a file with 0.76 million lines of LLVM IR</p>



<a name="203704484"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704484" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704484">(Jul 13 2020 at 11:42)</a>:</h4>
<p>and almost 15k <code>define</code>s</p>



<a name="203704485"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704485" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704485">(Jul 13 2020 at 11:42)</a>:</h4>
<p>uhm</p>



<a name="203704514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704514">(Jul 13 2020 at 11:42)</a>:</h4>
<p>just from mentioning <code>DEFAULT_QUERY_PROVIDERS</code> at runtime</p>



<a name="203704539"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704539" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704539">(Jul 13 2020 at 11:43)</a>:</h4>
<p>ofc if you just extract one function pointer out, all of the other stuff not actually needed can optimize out, so in my tests I didn't actually realize what the unoptimized IR had in it</p>



<a name="203704549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704549">(Jul 13 2020 at 11:43)</a>:</h4>
<p>so yeah something very cursed happens with <code>fn</code> pointers obtained through CTFE, sadly</p>



<a name="203704556"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704556" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704556">(Jul 13 2020 at 11:43)</a>:</h4>
<p>are you sure you're getting new copies in <code>rustc_interface</code> and the defines aren't just some weird way to specify functions from remote crates?</p>



<a name="203704562"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704562" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704562">(Jul 13 2020 at 11:43)</a>:</h4>
<p>those would be <code>declare</code>s</p>



<a name="203704564"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704564" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704564">(Jul 13 2020 at 11:44)</a>:</h4>
<p>ah</p>



<a name="203704606"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704606" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704606">(Jul 13 2020 at 11:44)</a>:</h4>
<p>15k <code>declare</code>s would be 15k of LLVM IR</p>



<a name="203704614"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704614" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704614">(Jul 13 2020 at 11:44)</a>:</h4>
<p>or maybe 30k to 45k, there might be comments or empty lines</p>



<a name="203704629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704629">(Jul 13 2020 at 11:44)</a>:</h4>
<p>and I saw some, there's definitely code in there</p>



<a name="203704634"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704634" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704634">(Jul 13 2020 at 11:44)</a>:</h4>
<p>kk</p>



<a name="203704647"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704647" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704647">(Jul 13 2020 at 11:44)</a>:</h4>
<p>so maybe I screwed up collecting function pointers in consts?</p>



<a name="203704689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704689">(Jul 13 2020 at 11:45)</a>:</h4>
<p>oh, yea I may not be visiting them in the "do we need a local instance" way</p>



<a name="203704694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704694">(Jul 13 2020 at 11:45)</a>:</h4>
<p>lalalala</p>



<a name="203704700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704700">(Jul 13 2020 at 11:45)</a>:</h4>
<p>/me totally knows what he's doing</p>



<a name="203704705"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704705" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704705">(Jul 13 2020 at 11:45)</a>:</h4>
<p>wondering if I can make this work with <code>lazy_static!</code> instead</p>



<a name="203704758"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704758" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704758">(Jul 13 2020 at 11:46)</a>:</h4>
<p>kinda sad but useful for comparison</p>



<a name="203704815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704815">(Jul 13 2020 at 11:46)</a>:</h4>
<p>and useful for custom drivers just fine tbh (as long as they access a field)</p>



<a name="203704841"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704841" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704841">(Jul 13 2020 at 11:47)</a>:</h4>
<p>nope, looks alright: <a href="https://github.com/rust-lang/rust/blob/0c04344d86f9598f20d9ec86fe87ea2a5d6ff8e6/src/librustc_mir/monomorphize/collector.rs#L1203">https://github.com/rust-lang/rust/blob/0c04344d86f9598f20d9ec86fe87ea2a5d6ff8e6/src/librustc_mir/monomorphize/collector.rs#L1203</a></p>



<a name="203704852"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704852" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704852">(Jul 13 2020 at 11:47)</a>:</h4>
<div class="codehilite"><pre><span></span><code>; &lt;rustc_middle::middle::resolve_lifetime::Set1&lt;T&gt; as rustc_serialize::serialize::Decodable&gt;::decode::{{closure}}
</code></pre></div>



<a name="203704859"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704859" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704859">(Jul 13 2020 at 11:47)</a>:</h4>
<p>random example of a function I have in here :P</p>



<a name="203704938"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203704938" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203704938">(Jul 13 2020 at 11:48)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> it's possible these might be closures, i.e. <code>providers.foo = |tcx, id| {...};</code> :/</p>



<a name="203705073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203705073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203705073">(Jul 13 2020 at 11:50)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> okay looking at the declare, it looks like most of them are correct</p>



<a name="203705302"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203705302" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203705302">(Jul 13 2020 at 11:54)</a>:</h4>
<p>I'll confirm they're closures then we can see what we can do</p>



<a name="203705528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203705528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203705528">(Jul 13 2020 at 11:57)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> slowly realizing we always serialize all closures' MIR because I doubt there's anything preventing every single closure from looking like a generic function</p>



<a name="203705660"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203705660" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203705660">(Jul 13 2020 at 11:59)</a>:</h4>
<p>/me stares at <code>i64* align 8 dereferenceable(25640) %_2</code></p>



<a name="203705668"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203705668" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203705668">(Jul 13 2020 at 11:59)</a>:</h4>
<p>hmm... that may be a low hanging fruit to look into for speedups</p>



<a name="203705669"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203705669" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203705669">(Jul 13 2020 at 11:59)</a>:</h4>
<p>that's how big <code>TyCtxt</code> is?</p>



<a name="203705694"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203705694" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203705694">(Jul 13 2020 at 11:59)</a>:</h4>
<p>anyway if I make the <code>Providers::EMPTY</code> functions into closures, they do indeed get codegen'd (well, 25 of them, those are the extern-only queries I believe)</p>



<a name="203705759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203705759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203705759">(Jul 13 2020 at 12:00)</a>:</h4>
<p>sorry, I mean the closure serialization</p>



<a name="203705769"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203705769" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203705769">(Jul 13 2020 at 12:00)</a>:</h4>
<p>but yea, 25kb is... <span aria-label="eyes" class="emoji emoji-1f440" role="img" title="eyes">:eyes:</span></p>



<a name="203705777"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203705777" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203705777">(Jul 13 2020 at 12:00)</a>:</h4>
<p>that was a rhetorical question from my part, sorry</p>



<a name="203705929"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203705929" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203705929">(Jul 13 2020 at 12:02)</a>:</h4>
<p><a href="http://perf.rust-lang.org">perf.rust-lang.org</a> measures stage2, right? so if I fix this <em>now</em>, we won't need to wait for beta?</p>



<a name="203705993"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203705993" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203705993">(Jul 13 2020 at 12:03)</a>:</h4>
<p>wow there's 42 matches for <code>providers\.\w+ = \|</code></p>



<a name="203706094"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203706094" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> mati865 <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203706094">(Jul 13 2020 at 12:04)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/247081-t-compiler.2Fperformance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22/near/203705929">said</a>:</p>
<blockquote>
<p><a href="http://perf.rust-lang.org">perf.rust-lang.org</a> measures stage2, right? so if I fix this <em>now</em>, we won't need to wait for beta?</p>
</blockquote>
<p>yes</p>



<a name="203706111"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203706111" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203706111">(Jul 13 2020 at 12:04)</a>:</h4>
<p>and 14 more that use the <code>field: |...| {...}</code> pattern</p>



<a name="203706154"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203706154" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203706154">(Jul 13 2020 at 12:05)</a>:</h4>
<p>so 56 queries are provided with closures</p>



<a name="203707316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203707316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203707316">(Jul 13 2020 at 12:17)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> okay so closures are not actually "linkable" unless <code>-Z share-generics</code> was enabled</p>



<a name="203707344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203707344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203707344">(Jul 13 2020 at 12:17)</a>:</h4>
<p>but, what if we made them non-generic?</p>



<a name="203707417"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203707417" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203707417">(Jul 13 2020 at 12:18)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> I think they hit other snags</p>



<a name="203707427"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203707427" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203707427">(Jul 13 2020 at 12:18)</a>:</h4>
<p><span aria-label="frown" class="emoji emoji-1f641" role="img" title="frown">:frown:</span></p>



<a name="203707483"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203707483" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203707483">(Jul 13 2020 at 12:18)</a>:</h4>
<p>like, they're not linkable at all I don't think, without that flag, which makes all sorts of things... idk</p>



<a name="203707517"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203707517" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203707517">(Jul 13 2020 at 12:19)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> but we can try to fix <code>substs.non_erasable_generics()</code> kind of logic to ignore the "<code>ClosureSubsts</code>" part of the equation and see if that changes anything?</p>



<a name="203707566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203707566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203707566">(Jul 13 2020 at 12:19)</a>:</h4>
<p>there's 9 callsites for <code>non_erasable_generics</code></p>



<a name="203707582"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203707582" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203707582">(Jul 13 2020 at 12:20)</a>:</h4>
<p>anyway I think I need some sleep</p>



<a name="203707759"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203707759" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203707759">(Jul 13 2020 at 12:21)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> that thing that worries me is something about "reachable" but maybe we can just treat closures like private functions</p>



<a name="203707815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203707815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203707815">(Jul 13 2020 at 12:22)</a>:</h4>
<p>so maybe it is just this generics nonsense</p>



<a name="203708952"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203708952" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203708952">(Jul 13 2020 at 12:34)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> us: splitting <del>hairs</del> <code>memcpy</code>s<br>
rustc: haha cross-crate closure monomorphizer goes brrrrrrrr</p>



<a name="203710194"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203710194" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203710194">(Jul 13 2020 at 12:48)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> okay I'm not going to sleep, I just had an idea... (what if we don't keep the <code>{Closure,Generator}Substs</code> extra stuff in the <code>Instance</code>? and limit it to <code>ty::{Closure,Generator}</code> instead?)</p>



<a name="203710282"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203710282" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203710282">(Jul 13 2020 at 12:49)</a>:</h4>
<p>it's not like anything in the body should refer to those """type parameters"""</p>



<a name="203716913"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203716913" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203716913">(Jul 13 2020 at 13:51)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> it seems I can compile the standard library :)</p>



<a name="203717790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203717790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203717790">(Jul 13 2020 at 13:58)</a>:</h4>
<blockquote>
<p>test result: FAILED. 10358 passed; 29 failed; 63 ignored; 0 measured; 0 filtered out</p>
</blockquote>



<a name="203717851"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203717851" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203717851">(Jul 13 2020 at 13:59)</a>:</h4>
<p>(I suspect I broke generators)</p>



<a name="203718007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203718007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203718007">(Jul 13 2020 at 14:00)</a>:</h4>
<p>although there's something weird happening with some error messages, it's almost like a fixed a long-standing issue??</p>



<a name="203718100"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203718100" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203718100">(Jul 13 2020 at 14:01)</a>:</h4>
<p>oh, I removed some inference, let me add that back in</p>



<a name="203719126"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203719126" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203719126">(Jul 13 2020 at 14:10)</a>:</h4>
<p>nope, doesn't help :/</p>



<a name="203721017"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203721017" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203721017">(Jul 13 2020 at 14:24)</a>:</h4>
<p>made some lunch, back now</p>



<a name="203721077"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203721077" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203721077">(Jul 13 2020 at 14:25)</a>:</h4>
<p>O_o you threw out the substs?</p>



<a name="203779169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203779169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203779169">(Jul 13 2020 at 22:27)</a>:</h4>
<p>(and fell asleep, back at it now)</p>



<a name="203780702"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203780702" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Léo Lanteri Thauvin <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203780702">(Jul 13 2020 at 22:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="119009">eddyb</span> <a href="#narrow/stream/247081-t-compiler.2Fperformance/topic/inlining.2Fconstifying.20all.20.22fn.20provide.22/near/203779169">said</a>:</p>
<blockquote>
<p>(and fell asleep, back at it now)</p>
</blockquote>
<p>You know what they say, night brings counsel <span aria-label="grinning face with smiling eyes" class="emoji emoji-1f601" role="img" title="grinning face with smiling eyes">:grinning_face_with_smiling_eyes:</span></p>



<a name="203781566"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203781566" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203781566">(Jul 13 2020 at 22:57)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> ugh it didn't actually make anything work, despite some closure instances definitely having empty substs now</p>



<a name="203781720"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203781720" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203781720">(Jul 13 2020 at 22:59)</a>:</h4>
<p>but maybe I can expose closures in <code>reachable_non_generics</code></p>



<a name="203781807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203781807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203781807">(Jul 13 2020 at 23:00)</a>:</h4>
<p>the "reachable" part worries me</p>



<a name="203782075"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203782075" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203782075">(Jul 13 2020 at 23:04)</a>:</h4>
<p>wat <a href="https://github.com/rust-lang/rust/blob/master/src/librustc_passes/reachable.rs#L101-L103">https://github.com/rust-lang/rust/blob/master/src/librustc_passes/reachable.rs#L101-L103</a></p>



<a name="203782249"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203782249" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203782249">(Jul 13 2020 at 23:06)</a>:</h4>
<p>I wonder who did that... <a href="https://github.com/rust-lang/rust/commit/da0a47a081a5beed3b2e638bd728fb0797f61561#diff-896d2c044f21cf78ca23be2b4b6a52a1R119-R121">https://github.com/rust-lang/rust/commit/da0a47a081a5beed3b2e638bd728fb0797f61561#diff-896d2c044f21cf78ca23be2b4b6a52a1R119-R121</a></p>



<a name="203782399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203782399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203782399">(Jul 13 2020 at 23:08)</a>:</h4>
<p>lol</p>



<a name="203782425"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203782425" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203782425">(Jul 13 2020 at 23:08)</a>:</h4>
<p>Does that do anything though?</p>



<a name="203782428"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203782428" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203782428">(Jul 13 2020 at 23:08)</a>:</h4>
<p>(I actually understand why I did that, it's preserving behavior even when the behavior was pointless and wasteful AFAICT now)</p>



<a name="203782561"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203782561" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203782561">(Jul 13 2020 at 23:11)</a>:</h4>
<p><span class="user-mention" data-user-id="211727">@Jonas Schievink</span> "oh I'll just make all <code>fn provide</code> <code>#[inline]</code> so <span class="user-mention" data-user-id="232545">@Joshua Nelson</span> can remove one <code>thread_local!</code>/<code>lazy_static!</code> in their PR" is turning into "closure monomorphization model is broken and I will fix it" and now this just because I went with <code>const fn</code> instead of <code>#[inline]</code> (although I suspect now that <code>#[inline]</code> would have the same issue)</p>



<a name="203782593"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203782593" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203782593">(Jul 13 2020 at 23:11)</a>:</h4>
<p>Good times!</p>



<a name="203782683"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203782683" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203782683">(Jul 13 2020 at 23:13)</a>:</h4>
<p>"rabbit holes to visit while taking turns with <span class="user-mention" data-user-id="132040">@Manish Goregaokar</span> doing <code>@bors retry</code> until it works"</p>



<a name="203782704"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203782704" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203782704">(Jul 13 2020 at 23:13)</a>:</h4>
<p>Or as I like to call it, "tuesday"</p>



<a name="203783013"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203783013" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203783013">(Jul 13 2020 at 23:18)</a>:</h4>
<p>huh, I didn't realize that building stage1 rustc was just a couple minutes, maybe something weird is happening:</p>
<div class="codehilite"><pre><span></span><code>    Finished release [optimized + debuginfo] target(s) in 2m 00s
</code></pre></div>



<a name="203783072"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203783072" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203783072">(Jul 13 2020 at 23:19)</a>:</h4>
<p>maybe some of my stuff is stale and that contributes to the new behavior, time to nuke everything again</p>



<a name="203783151"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203783151" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203783151">(Jul 13 2020 at 23:20)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> is it normal that some stale rlibs aren't removed from <code>stage1-rustc</code> anymore? I can get weird crashes due to the data not being valid for a newer <code>stage1/bin/rustc</code></p>



<a name="203785448"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203785448" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203785448">(Jul 13 2020 at 23:56)</a>:</h4>
<div class="codehilite"><pre><span></span><code>    Finished release [optimized + debuginfo] target(s) in 6m 41s
</code></pre></div>



<a name="203785465"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203785465" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203785465">(Jul 13 2020 at 23:57)</a>:</h4>
<p>yeah the 2m one is broken, I wonder what happened there</p>



<a name="203787082"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203787082" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203787082">(Jul 14 2020 at 00:21)</a>:</h4>
<p>anyway, I'm trying to figure out what to do. <span class="user-mention" data-user-id="232545">@Joshua Nelson</span> doesn't need more than some <code>lazy_static!</code> with default providers but that wouldn't change startup performance or put any restrictions on anything</p>



<a name="203787141"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203787141" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203787141">(Jul 14 2020 at 00:22)</a>:</h4>
<p>I can change how queries are provided, introducing a macro which uses functions instead of closures, and see where that gets me</p>



<a name="203787145"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203787145" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203787145">(Jul 14 2020 at 00:22)</a>:</h4>
<p>personally I'm ok with the current lazy_static</p>



<a name="203787150"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203787150" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203787150">(Jul 14 2020 at 00:23)</a>:</h4>
<p>so any performance things you do on top are just gravy ;)</p>



<a name="203787161"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203787161" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203787161">(Jul 14 2020 at 00:23)</a>:</h4>
<p>I can change closures to be more like functions, or maybe special-case coercing a closure to a fn pointer?</p>



<a name="203787211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203787211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203787211">(Jul 14 2020 at 00:24)</a>:</h4>
<p>since that seems like the operation where you don't want to cause cross-crate codegen</p>



<a name="203787231"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203787231" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203787231">(Jul 14 2020 at 00:24)</a>:</h4>
<p>I guess I can look into what reachability does in that case and replicate it for closure coercion to fn ptr</p>



<a name="203787303"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203787303" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203787303">(Jul 14 2020 at 00:26)</a>:</h4>
<p>I can hack it in to see if it helps, and then make like 4 more PRs for the various bits and bobs</p>



<a name="203787431"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203787431" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203787431">(Jul 14 2020 at 00:29)</a>:</h4>
<p>I feel like reachability approximates some aspects of monomorphization collection, but it's also different?</p>



<a name="203787507"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203787507" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203787507">(Jul 14 2020 at 00:31)</a>:</h4>
<p>it's handling <em>both</em> things that will be codegen'd locally, and things that require downstream monomorphizations, so they need serialized MIR (but do we use reachability to determine whether we serialize MIR? I thought we did not)</p>



<a name="203791978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203791978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203791978">(Jul 14 2020 at 01:57)</a>:</h4>
<p>oh <em>come on</em>, <code>InstanceDef::requires_inline</code> always returns <code>true</code> for closures</p>



<a name="203792199"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203792199" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203792199">(Jul 14 2020 at 02:03)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> ... success? I did something. I made a linker error</p>



<a name="203792264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203792264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203792264">(Jul 14 2020 at 02:04)</a>:</h4>
<p>presumably broke some assumptions and generated either duplicate instances of closures or they have the wrong export levels</p>



<a name="203792426"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203792426" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203792426">(Jul 14 2020 at 02:09)</a>:</h4>
<p>limiting it to monomorphic closures, at least the number of failures drops down</p>



<a name="203793371"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203793371" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203793371">(Jul 14 2020 at 02:31)</a>:</h4>
<p>heh it looks like <code>InstantiationMode::GloballyShared { may_conflict: false }</code> is responsible</p>



<a name="203793522"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203793522" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203793522">(Jul 14 2020 at 02:34)</a>:</h4>
<p>okay, I see, I couldn't actually use upstream closures <em>unless</em> they were compiled to allow it</p>



<a name="203793629"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203793629" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203793629">(Jul 14 2020 at 02:36)</a>:</h4>
<p>simplest thing I can do is set <code>may_conflict</code> to <code>true</code> and hope that, uhh, does something</p>



<a name="203793754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203793754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203793754">(Jul 14 2020 at 02:39)</a>:</h4>
<p>haha yeah that gets rid of the linker errors</p>



<a name="203793923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203793923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203793923">(Jul 14 2020 at 02:43)</a>:</h4>
<p>I wonder how expensive it would be to say that "reachable" closures behave like regular functions. and my definition of "reachable" is limited to closures which are coerced to a <code>fn</code> pointer</p>



<a name="203793943"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203793943" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203793943">(Jul 14 2020 at 02:43)</a>:</h4>
<p>4 more tests fail with my current approach, nice</p>



<a name="203793991"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203793991" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203793991">(Jul 14 2020 at 02:44)</a>:</h4>
<p>you know what, I'll fork the topic</p>



<a name="203794219"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203794219" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203794219">(Jul 14 2020 at 02:51)</a>:</h4>
<p>so yeah, current status:</p>
<ul>
<li><code>ty::Closure</code> keeps base substs + extra synthetics, <code>Instance</code> for closures <em>does not</em></li>
<li><code>reachable</code> pass treats closure-&gt;<code>fn</code> ptr coercions as "using" the closure, in the same way naming a function "uses" it</li>
<li><code>InstanceDef::generates_cgu_internal_copy</code> no longer always returns <code>true</code> for closures<ul>
<li>this is the only part of all of this that can ruin performance in non-<code>fn</code>-ptr cases, so we probably want to gate it on the <code>reachable</code> thing</li>
</ul>
</li>
</ul>



<a name="203794681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203794681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203794681">(Jul 14 2020 at 03:03)</a>:</h4>
<p>who's familiar with the intricacies of what we monomorphize and in which conditions? cc <span class="user-mention" data-user-id="123586">@nagisa</span> I guess</p>



<a name="203794700"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203794700" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203794700">(Jul 14 2020 at 03:03)</a>:</h4>
<p>wdym in which conditions? The collector will go through the items in a crate and monomorphize everything as things become concrete.</p>



<a name="203794701"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203794701" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203794701">(Jul 14 2020 at 03:04)</a>:</h4>
<p>ah heh I can't link <code>stage2/bin/rustc</code></p>



<a name="203794741"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203794741" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203794741">(Jul 14 2020 at 03:04)</a>:</h4>
<p><span class="user-mention" data-user-id="123586">@nagisa</span> I mean the weirder stuff like export levels</p>



<a name="203794751"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203794751" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203794751">(Jul 14 2020 at 03:04)</a>:</h4>
<p>oh /me shrugs, the implementation of the collector is the source of truth, sadly.</p>



<a name="203794753"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203794753" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203794753">(Jul 14 2020 at 03:04)</a>:</h4>
<p>okay so instead of duplicates, I now I get closures not being found, so I'm still not causing them to be properly exported or something</p>



<a name="203794771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203794771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203794771">(Jul 14 2020 at 03:05)</a>:</h4>
<p>I don’t actually know where the symbol visibility is decided, though.</p>



<a name="203794774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203794774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203794774">(Jul 14 2020 at 03:05)</a>:</h4>
<p>I feel like somewhere inside codegen_llvm but maybe not.</p>



<a name="203799807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203799807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203799807">(Jul 14 2020 at 05:22)</a>:</h4>
<p>okay back to it, thinking of trying <code>is_reachable_non_generic</code>, although I suspect recent successes were because of non-interesting cross-crate behavior</p>



<a name="203800336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203800336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203800336">(Jul 14 2020 at 05:35)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> so I don't think removing the closure/generator synthetics from <code>Instance</code> actually has a practical effect, so I can open a PR with that at least without worrying</p>



<a name="203800346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203800346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203800346">(Jul 14 2020 at 05:35)</a>:</h4>
<p>the reachability-based stuff looks like a huge hack and I still don't have it working, but I might still open a PR for it</p>



<a name="203800978"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203800978" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203800978">(Jul 14 2020 at 05:52)</a>:</h4>
<p>oh, right, what's broken now is <code>-&gt; impl Iterator</code> because that one also marks closures as reachable</p>



<a name="203800983"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203800983" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203800983">(Jul 14 2020 at 05:52)</a>:</h4>
<p>so I can't abuse reachability for that, fun</p>



<a name="203801122"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203801122" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203801122">(Jul 14 2020 at 05:56)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> I think the solution might just be to make a <code>provide!</code> macro that uses functions instead (like <code>rustc_metadata</code> does it, but more general), since we can do that without requiring the user to write the types for the arguments/return (as they are available globally based on the query name)</p>



<a name="203801191"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203801191" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203801191">(Jul 14 2020 at 05:58)</a>:</h4>
<p>it's not worth it to mess with the closure codegen and cause who knows what, even if limited to closures reified to <code>fn</code> pointers</p>



<a name="203801193"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203801193" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203801193">(Jul 14 2020 at 05:58)</a>:</h4>
<p>and in most cases the devirtualization through <code>fn</code> pointers in CTFE is cool</p>



<a name="203801195"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203801195" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203801195">(Jul 14 2020 at 05:58)</a>:</h4>
<p>so <em>shrug</em></p>



<a name="203801585"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203801585" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203801585">(Jul 14 2020 at 06:09)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> so yeah I give up lol <a href="https://github.com/rust-lang/rust/pull/74283">https://github.com/rust-lang/rust/pull/74283</a></p>



<a name="203801598"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203801598" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203801598">(Jul 14 2020 at 06:09)</a>:</h4>
<p>I think I know how to make it work but I'd need to add a query or change <code>reachable_set</code> to return two things, and it's just not worth it</p>



<a name="203801661"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203801661" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203801661">(Jul 14 2020 at 06:10)</a>:</h4>
<p>I'm also terrified of what bugs might arise (other than the ones that I'm tripping over locally lol) when changing some of these things</p>



<a name="203808177"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203808177" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203808177">(Jul 14 2020 at 08:07)</a>:</h4>
<p>that was a rollercoaster to read</p>



<a name="203875241"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203875241" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203875241">(Jul 14 2020 at 19:19)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> remember the 29 failures? that I never bothered fixing? I think they were just because of what I changed about <code>type_of</code> for closures/generators and "abort if errors" checkpoints in the compiler</p>



<a name="203875264"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203875264" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203875264">(Jul 14 2020 at 19:19)</a>:</h4>
<p>about to find out if removing that one.... yeah it fixes it lol</p>



<a name="203876740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/247081-t-compiler/performance/topic/closures%20used%20as%20fn%20pointers%20may%20be%20codegen%27d%20downstream/near/203876740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> eddyb <a href="https://rust-lang.github.io/zulip_archive/stream/247081-t-compiler/performance/topic/closures.20used.20as.20fn.20pointers.20may.20be.20codegen&#x27;d.20downstream.html#203876740">(Jul 14 2020 at 19:32)</a>:</h4>
<p>anyway that goes into <a href="https://github.com/rust-lang/rust/pull/74341">https://github.com/rust-lang/rust/pull/74341</a></p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>